package com.pm.personal.controller;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pm.entity.Comm;
import com.pm.entity.Home;
import com.pm.entity.User;
import com.pm.exception.MyException;
import com.pm.personal.biz.SecurityBiz;
import com.pm.personal.biz.UserBiz;



@Controller
public class SecurityController {
	@Autowired
    private SecurityBiz securityBiz;
	
	@Autowired
	private UserBiz userBiz;

    
    @RequestMapping("/login")
    public String login(String phone, String password){
      
			try {
				System.out.println("-----------------1------------------");
				securityBiz.login(phone, password);
				System.out.println("-----------------2------------------");
				
			} catch (MyException e) {
				System.out.println("-----------------4------------------");
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return "redirect:/list";
  
    }
    @RequestMapping("/list")
    @ResponseBody
    @RequiresAuthentication
    public String list(){
    	System.out.println(123);
    	System.out.println(123);
    	System.out.println(123);
    	return null;
    }
    @RequestMapping("/user")
    @ResponseBody
    public Comm findAll(){
    	
    	User user = userBiz.findUserByPhone("13264895158");
    	return user.getComm();
    	//return user.getHome();
    	
    	
    }

    
}
